<cfcomponent displayname="issues" output="false">
	<!---
	PROPERTIES
	--->
	<cfset variables.instance = StructNew() />

	<!---
	INITIALIZATION / CONFIGURATION
	--->
	<cffunction name="init" access="public" returntype="trac_fu.model.issues.issues" output="false">
		<cfargument name="id" type="string" required="false" default="" />
		<cfargument name="projectidfk" type="string" required="false" default="" />
		<cfargument name="created" type="string" required="false" default="" />
		<cfargument name="updated" type="string" required="false" default="" />
		<cfargument name="name" type="string" required="false" default="" />
		<cfargument name="useridfk" type="string" required="false" default="" />
		<cfargument name="creatoridfk" type="string" required="false" default="" />
		<cfargument name="description" type="string" required="false" default="" />
		<cfargument name="history" type="string" required="false" default="" />
		<cfargument name="isbug" type="string" required="false" default="" />
		<cfargument name="locusidfk" type="string" required="false" default="" />
		<cfargument name="severityidfk" type="string" required="false" default="" />
		<cfargument name="statusidfk" type="string" required="false" default="" />
		<cfargument name="relatedurl" type="string" required="false" default="" />
		<cfargument name="attachment" type="string" required="false" default="" />
		<cfargument name="publicid" type="string" required="false" default="" />
		<cfargument name="duedate" type="string" required="false" default="" />
		
		<!--- run setters --->
		<cfset setid(arguments.id) />
		<cfset setprojectidfk(arguments.projectidfk) />
		<cfset setcreated(arguments.created) />
		<cfset setupdated(arguments.updated) />
		<cfset setname(arguments.name) />
		<cfset setuseridfk(arguments.useridfk) />
		<cfset setcreatoridfk(arguments.creatoridfk) />
		<cfset setdescription(arguments.description) />
		<cfset sethistory(arguments.history) />
		<cfset setisbug(arguments.isbug) />
		<cfset setlocusidfk(arguments.locusidfk) />
		<cfset setseverityidfk(arguments.severityidfk) />
		<cfset setstatusidfk(arguments.statusidfk) />
		<cfset setrelatedurl(arguments.relatedurl) />
		<cfset setattachment(arguments.attachment) />
		<cfset setpublicid(arguments.publicid) />
		<cfset setduedate(arguments.duedate) />
		
		<cfreturn this />
 	</cffunction>

	<!---
	PUBLIC FUNCTIONS
	--->
	<cffunction name="setMemento" access="public" returntype="trac_fu.model.issues.issues" output="false">
		<cfargument name="memento" type="struct" required="yes"/>
		<cfset variables.instance = arguments.memento />
		<cfreturn this />
	</cffunction>
	<cffunction name="getMemento" access="public" returntype="struct" output="false" >
		<cfreturn variables.instance />
	</cffunction>

	<cffunction name="validate" access="public" returntype="array" output="false">
		<cfset var errors = arrayNew(1) />
		<cfset var thisError = structNew() />
		
		<!--- id --->
		<cfif (NOT len(trim(getid())))>
			<cfset thisError.field = "id" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "id is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getid())) AND NOT IsSimpleValue(trim(getid())))>
			<cfset thisError.field = "id" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "id is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getid())) GT 50)>
			<cfset thisError.field = "id" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "id is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- projectidfk --->
		<cfif (NOT len(trim(getprojectidfk())))>
			<cfset thisError.field = "projectidfk" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "projectidfk is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getprojectidfk())) AND NOT IsSimpleValue(trim(getprojectidfk())))>
			<cfset thisError.field = "projectidfk" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "projectidfk is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getprojectidfk())) GT 35)>
			<cfset thisError.field = "projectidfk" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "projectidfk is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- created --->
		<cfif (NOT len(trim(getcreated())))>
			<cfset thisError.field = "created" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "created is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getcreated())) AND NOT isDate(trim(getcreated())))>
			<cfset thisError.field = "created" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "created is not a date" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- updated --->
		<cfif (NOT len(trim(getupdated())))>
			<cfset thisError.field = "updated" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "updated is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getupdated())) AND NOT isDate(trim(getupdated())))>
			<cfset thisError.field = "updated" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "updated is not a date" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- name --->
		<cfif (NOT len(trim(getname())))>
			<cfset thisError.field = "name" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "name is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getname())) AND NOT IsSimpleValue(trim(getname())))>
			<cfset thisError.field = "name" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "name is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getname())) GT 255)>
			<cfset thisError.field = "name" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "name is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- useridfk --->
		<cfif (NOT len(trim(getuseridfk())))>
			<cfset thisError.field = "useridfk" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "useridfk is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getuseridfk())) AND NOT IsSimpleValue(trim(getuseridfk())))>
			<cfset thisError.field = "useridfk" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "useridfk is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getuseridfk())) GT 35)>
			<cfset thisError.field = "useridfk" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "useridfk is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- creatoridfk --->
		<cfif (len(trim(getcreatoridfk())) AND NOT IsSimpleValue(trim(getcreatoridfk())))>
			<cfset thisError.field = "creatoridfk" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "creatoridfk is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getcreatoridfk())) GT 35)>
			<cfset thisError.field = "creatoridfk" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "creatoridfk is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- description --->
		<cfif (NOT len(trim(getdescription())))>
			<cfset thisError.field = "description" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "description is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getdescription())) AND NOT IsSimpleValue(trim(getdescription())))>
			<cfset thisError.field = "description" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "description is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getdescription())) GT 1073741823)>
			<cfset thisError.field = "description" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "description is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- history --->
		<cfif (NOT len(trim(gethistory())))>
			<cfset thisError.field = "history" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "history is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(gethistory())) AND NOT IsSimpleValue(trim(gethistory())))>
			<cfset thisError.field = "history" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "history is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(gethistory())) GT 1073741823)>
			<cfset thisError.field = "history" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "history is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- isbug --->
		<cfif (NOT len(trim(getisbug())))>
			<cfset thisError.field = "isbug" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "isbug is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getisbug())) AND NOT isBoolean(trim(getisbug())))>
			<cfset thisError.field = "isbug" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "isbug is not boolean" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- locusidfk --->
		<cfif (NOT len(trim(getlocusidfk())))>
			<cfset thisError.field = "locusidfk" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "locusidfk is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getlocusidfk())) AND NOT IsSimpleValue(trim(getlocusidfk())))>
			<cfset thisError.field = "locusidfk" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "locusidfk is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getlocusidfk())) GT 35)>
			<cfset thisError.field = "locusidfk" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "locusidfk is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- severityidfk --->
		<cfif (NOT len(trim(getseverityidfk())))>
			<cfset thisError.field = "severityidfk" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "severityidfk is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getseverityidfk())) AND NOT IsSimpleValue(trim(getseverityidfk())))>
			<cfset thisError.field = "severityidfk" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "severityidfk is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getseverityidfk())) GT 35)>
			<cfset thisError.field = "severityidfk" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "severityidfk is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- statusidfk --->
		<cfif (NOT len(trim(getstatusidfk())))>
			<cfset thisError.field = "statusidfk" />
			<cfset thisError.type = "required" />
			<cfset thisError.message = "statusidfk is required" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getstatusidfk())) AND NOT IsSimpleValue(trim(getstatusidfk())))>
			<cfset thisError.field = "statusidfk" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "statusidfk is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getstatusidfk())) GT 35)>
			<cfset thisError.field = "statusidfk" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "statusidfk is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- relatedurl --->
		<cfif (len(trim(getrelatedurl())) AND NOT IsSimpleValue(trim(getrelatedurl())))>
			<cfset thisError.field = "relatedurl" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "relatedurl is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getrelatedurl())) GT 255)>
			<cfset thisError.field = "relatedurl" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "relatedurl is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- attachment --->
		<cfif (len(trim(getattachment())) AND NOT IsSimpleValue(trim(getattachment())))>
			<cfset thisError.field = "attachment" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "attachment is not a string" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		<cfif (len(trim(getattachment())) GT 255)>
			<cfset thisError.field = "attachment" />
			<cfset thisError.type = "tooLong" />
			<cfset thisError.message = "attachment is too long" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- publicid --->
		<cfif (len(trim(getpublicid())) AND NOT isNumeric(trim(getpublicid())))>
			<cfset thisError.field = "publicid" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "publicid is not numeric" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<!--- duedate --->
		<cfif (len(trim(getduedate())) AND NOT isDate(trim(getduedate())))>
			<cfset thisError.field = "duedate" />
			<cfset thisError.type = "invalidType" />
			<cfset thisError.message = "duedate is not a date" />
			<cfset arrayAppend(errors,duplicate(thisError)) />
		</cfif>
		
		<cfreturn errors />
	</cffunction>

	<!---
	ACCESSORS
	--->
	<cffunction name="setid" access="public" returntype="void" output="false">
		<cfargument name="id" type="string" required="true" />
		<cfset variables.instance.id = arguments.id />
	</cffunction>
	<cffunction name="getid" access="public" returntype="string" output="false">
		<cfreturn variables.instance.id />
	</cffunction>

	<cffunction name="setprojectidfk" access="public" returntype="void" output="false">
		<cfargument name="projectidfk" type="string" required="true" />
		<cfset variables.instance.projectidfk = arguments.projectidfk />
	</cffunction>
	<cffunction name="getprojectidfk" access="public" returntype="string" output="false">
		<cfreturn variables.instance.projectidfk />
	</cffunction>

	<cffunction name="setcreated" access="public" returntype="void" output="false">
		<cfargument name="created" type="string" required="true" />
		<cfset variables.instance.created = arguments.created />
	</cffunction>
	<cffunction name="getcreated" access="public" returntype="string" output="false">
		<cfreturn variables.instance.created />
	</cffunction>

	<cffunction name="setupdated" access="public" returntype="void" output="false">
		<cfargument name="updated" type="string" required="true" />
		<cfset variables.instance.updated = arguments.updated />
	</cffunction>
	<cffunction name="getupdated" access="public" returntype="string" output="false">
		<cfreturn variables.instance.updated />
	</cffunction>

	<cffunction name="setname" access="public" returntype="void" output="false">
		<cfargument name="name" type="string" required="true" />
		<cfset variables.instance.name = arguments.name />
	</cffunction>
	<cffunction name="getname" access="public" returntype="string" output="false">
		<cfreturn variables.instance.name />
	</cffunction>

	<cffunction name="setuseridfk" access="public" returntype="void" output="false">
		<cfargument name="useridfk" type="string" required="true" />
		<cfset variables.instance.useridfk = arguments.useridfk />
	</cffunction>
	<cffunction name="getuseridfk" access="public" returntype="string" output="false">
		<cfreturn variables.instance.useridfk />
	</cffunction>

	<cffunction name="setcreatoridfk" access="public" returntype="void" output="false">
		<cfargument name="creatoridfk" type="string" required="true" />
		<cfset variables.instance.creatoridfk = arguments.creatoridfk />
	</cffunction>
	<cffunction name="getcreatoridfk" access="public" returntype="string" output="false">
		<cfreturn variables.instance.creatoridfk />
	</cffunction>

	<cffunction name="setdescription" access="public" returntype="void" output="false">
		<cfargument name="description" type="string" required="true" />
		<cfset variables.instance.description = arguments.description />
	</cffunction>
	<cffunction name="getdescription" access="public" returntype="string" output="false">
		<cfreturn variables.instance.description />
	</cffunction>

	<cffunction name="sethistory" access="public" returntype="void" output="false">
		<cfargument name="history" type="string" required="true" />
		<cfset variables.instance.history = arguments.history />
	</cffunction>
	<cffunction name="gethistory" access="public" returntype="string" output="false">
		<cfreturn variables.instance.history />
	</cffunction>

	<cffunction name="setisbug" access="public" returntype="void" output="false">
		<cfargument name="isbug" type="string" required="true" />
		<cfset variables.instance.isbug = arguments.isbug />
	</cffunction>
	<cffunction name="getisbug" access="public" returntype="string" output="false">
		<cfreturn variables.instance.isbug />
	</cffunction>

	<cffunction name="setlocusidfk" access="public" returntype="void" output="false">
		<cfargument name="locusidfk" type="string" required="true" />
		<cfset variables.instance.locusidfk = arguments.locusidfk />
	</cffunction>
	<cffunction name="getlocusidfk" access="public" returntype="string" output="false">
		<cfreturn variables.instance.locusidfk />
	</cffunction>

	<cffunction name="setseverityidfk" access="public" returntype="void" output="false">
		<cfargument name="severityidfk" type="string" required="true" />
		<cfset variables.instance.severityidfk = arguments.severityidfk />
	</cffunction>
	<cffunction name="getseverityidfk" access="public" returntype="string" output="false">
		<cfreturn variables.instance.severityidfk />
	</cffunction>

	<cffunction name="setstatusidfk" access="public" returntype="void" output="false">
		<cfargument name="statusidfk" type="string" required="true" />
		<cfset variables.instance.statusidfk = arguments.statusidfk />
	</cffunction>
	<cffunction name="getstatusidfk" access="public" returntype="string" output="false">
		<cfreturn variables.instance.statusidfk />
	</cffunction>

	<cffunction name="setrelatedurl" access="public" returntype="void" output="false">
		<cfargument name="relatedurl" type="string" required="true" />
		<cfset variables.instance.relatedurl = arguments.relatedurl />
	</cffunction>
	<cffunction name="getrelatedurl" access="public" returntype="string" output="false">
		<cfreturn variables.instance.relatedurl />
	</cffunction>

	<cffunction name="setattachment" access="public" returntype="void" output="false">
		<cfargument name="attachment" type="string" required="true" />
		<cfset variables.instance.attachment = arguments.attachment />
	</cffunction>
	<cffunction name="getattachment" access="public" returntype="string" output="false">
		<cfreturn variables.instance.attachment />
	</cffunction>

	<cffunction name="setpublicid" access="public" returntype="void" output="false">
		<cfargument name="publicid" type="string" required="true" />
		<cfset variables.instance.publicid = arguments.publicid />
	</cffunction>
	<cffunction name="getpublicid" access="public" returntype="string" output="false">
		<cfreturn variables.instance.publicid />
	</cffunction>

	<cffunction name="setduedate" access="public" returntype="void" output="false">
		<cfargument name="duedate" type="string" required="true" />
		<cfset variables.instance.duedate = arguments.duedate />
	</cffunction>
	<cffunction name="getduedate" access="public" returntype="string" output="false">
		<cfreturn variables.instance.duedate />
	</cffunction>


	<!---
	DUMP
	--->
	<cffunction name="dump" access="public" output="true" return="void">
		<cfargument name="abort" type="boolean" default="false" />
		<cfdump var="#variables.instance#" />
		<cfif arguments.abort>
			<cfabort />
		</cfif>
	</cffunction>

</cfcomponent>